﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Business_Layer;
using System.Drawing;

namespace Control_Layer
{
    // See UseCase:
    // UCD00-ADDITIONS (00)
    public class CCAddBody
    {
        private Service service;
        private Project project;

        public CCAddBody()
        {
            service = Service.GetInstance;
            project = service.GetProject;
        }

        /// <summary>
        /// Adds a new body to the current mindmap.
        /// </summary>
        /// <param name="sx">The X Coordinate to start the body.</param>
        /// <param name="sy">The Y Coordinate to start the body.</param>
        /// <param name="ex">The X Coordinate to end the body.</param>
        /// <param name="ey">The Y Coordinate to end the body.</param>
        /// <param name="text">The text that should appear in the body.</param>
        /// <returns></returns>
        public Bitmap Add(int sx, int sy, int ex, int ey, string text)
        {
            return project.AddComponent(TypeComponent.Body, sx, sy, ex, ey, text);
        }

        /// <summary>
        /// Set an alternate funtion to this body.
        /// </summary>
        /// <returns></returns>
        public int Alternate()
        {
            string name = project.AlternateAction();

            if (name != null)
            {
                CCSelectMindmap ccSelectMindmap = new CCSelectMindmap();
                int id = ccSelectMindmap.GetMindmaps().IndexOf(name);

                if (id != -1)
                {
                    ccSelectMindmap.SelectMindmap(id);
                    return id;
                }
            }

            return -1;
        }
    }
}